<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增Keystore')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-keystrore-add" name="form-keystrore-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">keystore名称：</label>
            <div class="col-sm-8">
                <input id="keystoreName" name="keystoreName" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">alg：</label>
            <div class="col-sm-8">
                <input id="alg" name="alg" class="form-control" value="RSA" type="text" readonly required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">alias：</label>
            <div class="col-sm-8">
                <input id="alias" name="alias" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">cn：</label>
            <div class="col-sm-8">
                <input id="cn" name="cn" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 名字与姓氏</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">ou：</label>
            <div class="col-sm-8">
                <input id="ou" name="ou" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 组织单位名称</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">o：</label>
            <div class="col-sm-8">
                <input id="o" name="o" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 组织名称</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">l：</label>
            <div class="col-sm-8">
                <input id="l" name="l" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 城市或区域名称</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">st：</label>
            <div class="col-sm-8">
                <input id="st" name="st" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 省/市/自治区名称</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">c：</label>
            <div class="col-sm-8">
                <input id="c" name="c" class="form-control" type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 国家/地区代码</span>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">keystorePass：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="keystorePass" name="keystorePass" placeholder="请输入keystorePass"
                           class="form-control"
                           type="password" th:value="${@config.getKey('sys.keystore.initPass')}" required>
                    <span class="input-group-addon" title="鼠标按下keystorePass"
                          onmousedown="$('#keystorePass').attr('type','text')"
                          onmouseup="$('#keystorePass').attr('type','password')"><i class="fa fa-key"></i></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">privateKeyPass：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="privateKeyPass" name="privateKeyPass" placeholder="请输入privateKeyPass"
                           class="form-control"
                           type="password" th:value="${@config.getKey('sys.keystore.initPass')}" required>
                    <span class="input-group-addon" title="鼠标按下privateKeyPass"
                          onmousedown="$('#privateKeyPass').attr('type','text')"
                          onmouseup="$('#privateKeyPass').attr('type','password')"><i class="fa fa-key"></i></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">显示顺序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="sort" id="sort" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "system/keystore";

    $("#form-keystrore-add").validate({
        onkeyup: false,
        rules: {
            keystoreName: {
                remote: {
                    url: prefix + "/checkKeystoreNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "keystoreName": function () {
                            return $.common.trim($("#keystoreName").val());
                        }
                    }
                }
            },
        },
        messages: {
            "keystoreName": {
                remote: "keystore名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-keystrore-add').serialize());
        }
    }
</script>
</body>
</html>
